package com.zzxx.mapper;

import com.zzxx.domain.Orders;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OrdersMapper {
    @Results(id = "orderMap", value = {
            @Result(column = "id", property = "id"),
            @Result(column = "orderNum", property = "orderNum"),
            @Result(column = "orderTime", property = "orderTime"),
            @Result(column = "orderStatus", property = "orderStatus"),
            @Result(column = "peopleCount", property = "peopleCount"),
            @Result(column = "payType", property = "payType"),
            @Result(column = "productDesc", property = "productDesc"),
            @Result(column = "orderDesc", property = "orderDesc"),
            @Result(column = "productId", property = "product",
                    one = @One(select = "com.zzxx.mapper.ProductMapper.findProductById")),
            @Result(column = "memberId", property = "member",
                    one = @One(select = "com.zzxx.mapper.MemberMapper.findMemberById")),
            @Result(column = "id", property = "travellers",
                    many = @Many(select = "com.zzxx.mapper.TravellerMapper.findByOId"))
    })
    @Select("select * from orders")
    List<Orders> findAll();

    @Select("select * from orders where id = #{id}")
    @ResultMap("orderMap")
    Orders findById(String id);
}
